package com.example.server.controller;

import com.example.server.entity.Collect;
import com.example.server.entity.Product;
import com.example.server.entity.User;
import com.example.server.service.CollectService;
import com.example.server.util.Util;
import lombok.experimental.FieldNameConstants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("collect")
public class CollectController extends BaseController{
    private final CollectService collectService;

    public CollectController(CollectService collectService) {
        this.collectService = collectService;
    }
    @PostMapping("create")
    @ResponseBody
    private boolean create(@RequestBody Collect collect){
        collectService.create(collect);
        return true;
    }

    @GetMapping("queryByUid")
    @ResponseBody
    private List<Collect> queryByUid(@RequestParam BigInteger uid){
        List<Collect> list = collectService.queryList("queryByUid",uid);
        return list;
    }

    @GetMapping("queryById")
    @ResponseBody
    private Collect queryById(@RequestParam BigInteger collid){
        Collect collect = collectService.queryOne("queryById",collid);
        return collect;
    }

    @DeleteMapping("removeById")
    @ResponseBody
    private boolean queryById(@RequestBody Map<String,BigInteger> map){
        BigInteger collid = map.get("collid");
        collectService.removeById(collid);
        return true;
    }
}
